package com.samples.gui;

import java.sql.SQLException;
import java.util.List;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.samples.dbConnection.ConnectToWorldDB;
import com.samples.entity.City;
import com.samples.entity.Country;

public class NorthPanel {

	private JPanel northPanel;
	private JComboBox<City> cmbCity;
	private JLabel lblCity;
	private JComboBox<Country> cmbCountry;
	private JLabel lblCountry;

	public NorthPanel() {
		northPanel = new JPanel();
		lblCity = new JLabel("City: ");
		cmbCity = new JComboBox<>();
		lblCountry = new JLabel("Country: ");
		cmbCountry = new JComboBox<>();
		northPanel.add(lblCity);
		northPanel.add(cmbCity);
		northPanel.add(lblCountry);
		northPanel.add(cmbCountry);
	}

	public JPanel getNorthPanel() {
		return northPanel;
	}

	public void dataBindToCmbCity() throws SQLException {
		DefaultComboBoxModel<City> model = new DefaultComboBoxModel<>();
		List<City> cityList = ConnectToWorldDB.connectToCityDB();
		for (City city : cityList) {
			model.addElement(city);
		}
		cmbCity.setModel(model);

	}
}
